# -*- coding: utf-8 -*-
# @Time        :2025/3/1 15:14
# @Author      :文刀水寿
# @File        : 9_爬虫_urllib_ajax的get请求豆瓣电影第一页.py
"""
 @Description :
"""
import urllib.request

url = 'https://movie.douban.com/j/chart/top_list?type=5&interval_id=100%3A90&action=&start=0&limit=20'

headers = {
    'user-agent': 'Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.0.0 Mobile Safari/537.36 Edg/133.0.0.0'
}

# 请求对象的定制
request = urllib.request.Request(url=url, headers=headers)

# 模拟浏览器向服务器发送请求
response = urllib.request.urlopen(request)

content = response.read().decode('utf-8')

with open('douban.json', 'w', encoding='utf-8') as fp:
    fp.write(content)
